<!--
 * @Author: zhangxiangsheng 1026583651@qq.com
 * @Date: 2024-04-15 17:10:30
 * @LastEditors: 花香蝶自来 1026583651@qq.com
 * @LastEditTime: 2024-05-29 20:06:29
 * @FilePath: \crm\pages\list\list.vue
 * @Description: 
 * 
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. 
-->
<template>
  <view>
    <!-- leftText="取消" :leftIcon="leftIcon" -->
    <u-navbar :title="title"></u-navbar>
    <formz ref="formz" :inputs="inputs" :data="data"></formz>
    <bottombox>
      <u-button type="error" :loading="loading" text="保存" @click="save"></u-button>
    </bottombox>
  </view>
</template>

<script>
import { getAdd, getupdate ,getPageid} from "@/apis/customer/jcCustomInvoice.js";
export default {
  data() {
    return {
      leftIcon: "",
      title: "新增发票",
      data: {},
      loading: false,
      inputs: [
        {
          label: "申请编号",
          value: "number",

          rules: [{ required: true, message: '请输入申请编号', trigger: 'blur', },], iscard: "before"
        },
        {
          label: "选择客户",
          value: "customId",
          type: "customers",
          // rules: [{ required: true, message: '请选择客户', trigger: 'blur', },],
        },
        {
          label: "开票类型",
          value: "type",
          type: "select",
          option: [
            { label: "普票", value: "0" },
            { label: "专票", value: "1" },
          ],
          defaultValue: "0",
          rules: [{ required: true, message: '请选择开票类型', trigger: 'blur', },],

        },
        { label: "订单金额", fl: 100, value: "orderAmount", defaultValue: "0", rules: [{ required: true, message: '请输入订单金额', trigger: 'blur', },] },
        { label: "开票金额", fl: 100, value: "invoiceAmount", defaultValue: "0", rules: [{ required: true, message: '请输入开票金额', trigger: 'blur', },] },
        { label: "备注", type: "textarea", value: "remarks", iscard: "after" },
        { label: "订单信息", type: "orderIds", value: "orderIds", iscard: "card", rules: [{ required: true, message: '请选择开票订单', trigger: 'blur', },], },

        { label: "抬头类型", value: "riseType", type: "select", option: [{ label: "单位", value: "0" }, { label: "个人", value: "1" }], rules: [{ required: true, message: '请选择抬头类型', trigger: 'blur', },], defaultValue: "0", iscard: "before" },
        { label: "抬头", value: "rise", rules: [{ required: true, message: '请输入抬头', trigger: 'blur', },], },
        { label: "识别号", value: "identifier", rules: [{ required: true, message: '请输入纳税人识别号', trigger: 'blur', },], },
        { label: "开户行", value: "bank", rules: [{ required: true, message: '请输入开户行', trigger: 'blur', },], },
        { label: "开户账号", value: "account", rules: [{ required: true, message: '请输入开户账号', trigger: 'blur', },], },
        { label: "开票地址", value: "address", rules: [{ required: true, message: '请输入开票地址', trigger: 'blur', },], },
        { label: "开票电话", value: "phone", rules: [{ required: true, message: '请输入开票电话', trigger: 'blur', },], iscard: "after" },
      ],
	  query:{}
    };
  },
  onLoad(query) {
  	this.query=query;
	this.init()
  },
  mounted() {
    // getCompanyList()
  },
  methods: {
	 async init(){
		  this.title=this.query.id?"修改发票":"新增发票"
		  this.data={}
		  if(this.query.id){
			   let data=await getPageid(this.query.id)
			    this.data=data
		  }
		 
	  }, 
    async save() {
      let data = await this.$refs.formz.validate();
      this.loading = true;
      if (data.id) {
        await getupdate(data)
      } else {
        await getAdd(data)
      }
      this.loading = false;
      this.$z.back();
    }
  },
};
</script>

<style lang="scss">
page {
  background: #f2f4f5;
}
</style>
